﻿using System;
using System.Collections.Generic;

using Fuse8.DomainFramework.Common;

namespace Fuse8.ContentManagementFramework.SystemFacade.Workflow
{
    [Serializable]
    public abstract class CmsWorkflowState
    {
        public abstract string StateName { get; }

        public abstract int StateId { get; }

        public virtual int? UserGroupId { get; set; }

        public virtual int? UserId { get; set; }

        public virtual string Notes { get; set; }

        public virtual object AdditionalInformation { get; set; }

        public virtual string AdditionalInformationType 
        {
            get
            {
                return string.Empty;
            }
        }
        
        public virtual string StateTitle
        {
            get
            {
                return StateName;
            }
        }

        public virtual bool IsFinalState
        {
            get
            {
                return false;
            }
        }

        public virtual IEnumerable<CmsWorkflowStateTransition> StateTransitions 
        {
            get
            {
                return new List<CmsWorkflowStateTransition>();
            }
        }

        public virtual void Run()
        { }

        public override bool Equals(object obj)
        {
            Guard.ArgumentNotNull(obj, "obj");

            return StateId.Equals((obj as CmsWorkflowState).StateId);
        }

        public override int GetHashCode()
        {
            return StateId.GetHashCode();
        }
    }

    [Serializable]
    public class CmsWorkflowInitialState : CmsWorkflowState
    {
        public override string StateTitle
        {
            get 
            {
                return "Draft";
            }
        }

        public override string StateName
        {
            get 
            {
                return "Initial";
            }
        }

        public override int StateId
        {
            get 
            {
                return 0;
            }
        }
    }
}
